import path from 'path'
import common from './common'

// let iceClass = 'EvidenceCourt.ICEHelper'
let iceClass = 'EvidenceCourt.UnifiedBusiness2'
let dllPath = path.resolve(process.execPath || '', '..\\EvidenceCourt.dll')

export default {
  async SetAppSetting (arg) {
    try {
      return await common.ExecuteServer(dllPath, iceClass, 'SetAppSetting', arg)
    } catch (error) {
      throw error
    }
  },
  async GetUnitTreeList (arg) {
    try {
      return await common.ExecuteServer(dllPath, iceClass, 'GetUnitTreeList', arg)
    } catch (error) {
      throw error
    }
  },
  async GetLoginUserInfo (arg) {
    try {
      return await common.ExecuteServer(dllPath, iceClass, 'LoginVerification', arg)
    } catch (error) {
      throw error
    }
  },
  async GetCaseList (arg) {
    try {
      return await common.ExecuteServer(dllPath, iceClass, 'GetCaseList', arg)
    } catch (error) {
      throw error
    }
  },
  async GetCases (arg) {
    try {
      return await common.ExecuteServer(dllPath, iceClass, 'GetCases', arg)
    } catch (error) {
      throw error
    }
  },
  async GetCaseInfo (arg) {
    try {
      return await common.ExecuteServer(dllPath, iceClass, 'GetCaseInfo', arg)
    } catch (error) {
      throw error
    }
  },
  async GetEvidenceMaterialCatalog (arg) {
    try {
      return await common.ExecuteServer(dllPath, iceClass, 'GetEvidenceMaterialCatalog', arg)
    } catch (error) {
      throw error
    }
  },
  async InitDatabaseFile (arg) {
    try {
      arg.ip = localStorage.getItem('gszsIP')
      return await common.ExecuteServer(dllPath, iceClass, 'InitDatabaseFile', arg)
    } catch (error) {
      throw error
    }
  },
  async DownLoadEvidenceMaterial (arg) {
    try {
      arg.dbPath = arg.dbPath ? arg.dbPath : null
      arg.eventName = 'DownloadFile'
      return await common.ExecuteServer(dllPath, iceClass, 'DownLoadEvidenceMaterial', arg)
    } catch (error) {
      throw error
    }
  },
  async GetVersionRecords (DBFile) {
    try {
      return await common.ExecuteServer(dllPath, iceClass, 'GetVersionRecords', {DBFile})
    } catch (error) {
      throw error
    }
  }
}
